package cn.bestick.weightrecord.util;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * Created by IntelliJ IDEA.
 * User: Bestick
 * Date: 2016/7/8
 * Time: 18:51
 * Url: http://www.bestick.cn
 * Copyright © 2015-2016 Bestick All rights reserved
 * -----------------------------------------------------------
 * 会当凌绝顶，一览众山小。
 */
public class DBUtil {

    public Connection getCon() throws Exception {
        Class.forName(PropertiesUtil.getValue("jdbcName"));
        Connection con = DriverManager.getConnection(
                PropertiesUtil.getValue("dbUrl"),
                PropertiesUtil.getValue("dbUserName"),
                PropertiesUtil.getValue("dbPassword"));
        return con;
    }

    public void closeCon(Connection con) throws Exception {
        if (con != null) {
            con.close();
        }
    }
}
